package com.wswy.wzcx.widget.utils;

import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import com.wswy.wzcx.R;

public class ScalePageTransformer implements ViewPager.PageTransformer {

    private static final String TAG = "ScalePageTransformer";

    private static final float SCALE_MAX = 0.8f;

    private boolean disableTransformer = false;

    public void setDisableTransformer(boolean disableTransformer) {
        this.disableTransformer = disableTransformer;
    }

    @Override
    public void transformPage(View page, float position) {

        if (disableTransformer){
            return;
        }

        float scale = (position < 0)
                ? ((1 - SCALE_MAX) * position + 1)
                : ((SCALE_MAX - 1) * position + 1);

        if (position < 0) {
            page.setPivotX(page.getWidth());
            page.setPivotY(page.getHeight()/2);
        } else {
            page.setPivotX(0);
            page.setPivotY(page.getHeight()/2);
        }
        page.setScaleX(scale);
        page.setScaleY(scale);

    }
}